package com.kate.mall.bff.wx.config;

import org.redisson.Redisson;
import org.redisson.api.RedissonClient;
import org.redisson.config.Config;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.HashSet;
import java.util.Set;

/**
 * @author 新梦想.陈超
 * @version 2021.2
 * @Description: {TODO}
 * @date 2023/3/14 上午11:20
 */
@Configuration
public class MallRedissonConfig {
    @Value("${spring.redis.host}")
    private String host;
    @Value("${spring.redis.port}")
    private String port;
    @Value("${spring.redis.password}")
    private String password;


    @Bean
    public RedissonClient redissonClient(){
        Config config = new Config();
        //单机配置
        config.useSingleServer().setAddress("redis://"+host+":"+port).setPassword(password);
        //主从集群配置
//        Set<String> slaves = new HashSet<String>();
//        slaves.add("")
//        slaves.add("")
//        slaves.add("")
//        config.useMasterSlaveServers().setMasterAddress("").setPassword("").setSlaveAddresses(new String[]{"",""});
        return Redisson.create(config);
    }
}
